import java.util.Stack;

class Solution {
    public int evalRPN(String[] tokens) {
        Stack<Integer> s = new Stack<>();

        for(int i = 0;i<tokens.length;i++){
            if(!fun(tokens[i])){
                s.push(Integer.valueOf(tokens[i]));
            } else {
                Integer i2 = s.pop();
                Integer i1 = s.pop();
                s.push(fun2(tokens[i],i1,i2));
            }
        }
        return s.pop();
    }
    public boolean fun(String s){

        if(s.equals("+")
                || s.equals("-")
                || s.equals("*")
                || s.equals("/") ){
            return true;
        }
        return false;
    }
    public Integer fun2(String s,Integer i1,Integer i2) {
        if (s.equals("+")) {
            return i1 + i2;
        }
        if (s.equals("-")) {
            return i1 - i2;
        }
        if (s.equals("*")) {
            return i1 * i2;
        }
        return i1 / i2;
    }

    public static void main(String[] args) {
        Solution s = new Solution();
        String[] t = {"4","13","5","/","+"};
        s.evalRPN(t);
    }
}